const { Sequelize } = require('sequelize')
const configs = require('./config');
// const init = require('../model/init');
const sequelize = new Sequelize(
    configs.mysql.database,
    configs.mysql.user,
    configs.mysql.password, {
    host: configs.mysql.host,
    dialect: 'mysql',
    pool: {
        max: 5,
        min: 0,
        idle: 10000
    }
})
sequelize.authenticate().then(() => {
    console.log("数据库连接成功");
    // init().then(() => {
    //     console.log("表关系初始化完成");
    //   })
}).catch((err) => {
    console.error("数据库连接异常:" + err);
})
module.exports = sequelize